package controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;

@WebServlet("/userexit.do")
public class UserExitController extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession();
        //去除session
        session.removeAttribute("user");
        //如果记住登陆状态还需要去除cookie
        Cookie cook_name = new Cookie("username","");
        Cookie cook_pwd = new Cookie("upassword","");
        cook_name.setMaxAge(0);
        cook_pwd.setMaxAge(0);
        response.addCookie(cook_name);
        response.addCookie(	cook_pwd);

        response.sendRedirect("/index.jsp");

    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}
